#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@File    :   discreatize_by_kmeans_example.py    
@Contact :   raogx.vip@hotmail.com
@License :   (C)Copyright 2017-2018, Liugroup-NLPR-CASIA

@Modify Time      @Author    @Version    @Desciption
------------      -------    --------    -----------
2020/10/18 21:34   gxrao      1.0         None
'''

# import lib
import file.file as file
import pandas as pd
import os
import discretize.discretize as discretize

if __name__ == '__main__':
    kmeansDir = '../data/kmeans'
    surfix = '.csv'
    csvList = file.GetAllFileNameBySurfix(kmeansDir, surfix)

    cor_concide_rate_list = []
    for csvPath in csvList:
        data = pd.read_csv(os.path.join(kmeansDir, csvPath))
        for row in range(0, len(data)):
            cor_concide_rate_list.append(data.iat[row, 1])
            cor_concide_rate_list.append(data.iat[row, 2])
            cor_concide_rate_list.append(data.iat[row, 3])
            cor_concide_rate_list.append(data.iat[row, 4])
            cor_concide_rate_list.append(data.iat[row, 5])
            cor_concide_rate_list.append(data.iat[row, 6])

    data = pd.DataFrame({"cor_concide_rate": cor_concide_rate_list})
    data = data[u'cor_concide_rate']
    data_result = discretize.DiscretizeByKmeans(k=2, data=data)
    discretize.ClusterPlot(d=data_result, k=2, data=data).show()
